(function () {
    var currentIndex = 0;
    // nav active
    $(".nav-first").each(function () {
        this.onclick = function () {
            $(this).siblings().children('.nav-second').css('display','none');

            $(this).children(".nav-second").animate({height:'toggle'},function () {
                var showFlag =$(this).css("display");
                if(showFlag == 'block'){
                    $(this).prev().children().addClass('arrow-rotate')
                    $(this).parent().siblings().children('a').children('.icon-left-dir').removeClass('arrow-rotate')
                }
                else {
                    $(this).prev().children().removeClass('arrow-rotate')
                }

            });
            changeActive('mini-bar>ul>li',currentIndex,this)
        }
    });

    //nav-second stopPropagation()
    $(".nav-second>ul>li>a").each(function () {
        this.onclick = function (e) {

            $(".nav-second>ul>li>a").removeClass('nav-second-active').addClass('nav-second-normal');
            $(this).removeClass('nav-second-active').addClass('nav-second-active');
            e.stopPropagation()
        }
    })


    // switch mini-bar
    $("#home").click(function () {
        var showFlag = $(".inner-left").css("display");
        if(showFlag == "block"){
            $(".inner-left").css("display","none");
            $(".mini-bar").css("display","block");

        }
        else{
            $(".inner-left").css("display","block");
            $(".mini-bar").css("display","none");
        }
    })

    // mini-bar click
    $(".mini-bar>ul>li").each(function (e) {
        this.onclick = function () {
            $(".inner-left").css("display","block");
            $(".mini-bar").css("display","none");
            var temp = $(this).index();
            var str ;
            $(".nav-first:eq("+temp+")").children(".nav-second").css("display","block");
            $(".nav-first:eq("+temp+")").siblings().children(".nav-second").css("display","none");

            $(".nav-first:eq("+temp+")").children('a').children('.icon-left-dir').addClass('arrow-rotate');
            $(".nav-first:eq("+temp+")").siblings().children('a').children('.icon-left-dir').removeClass('arrow-rotate')


            $(this).prev().children().addClass('arrow-rotate')
            $(this).parent().siblings().children('a').children('.icon-left-dir').removeClass('arrow-rotate')

            changeActive('nav-first',currentIndex,this);


        }
    })


    // change active function
    function changeActive(selector,currentIndex,self){
        $(self).siblings().removeClass('nav-first-active');
        $(self).addClass('nav-first-active');
        currentIndex = $(self).index();

        switch (currentIndex){
            case 0:
            {
                $("."+selector+":eq(0)").addClass("nav-first-active")
                $("."+selector+":eq(0)").siblings().removeClass("nav-first-active")
            }
                break;
            case 1:
                $("."+selector+":eq(1)").addClass("nav-first-active")
                $("."+selector+":eq(1)").siblings().removeClass("nav-first-active")
                break;
            case 2:
                $("."+selector+":eq(2)").addClass("nav-first-active")
                $("."+selector+":eq(2)").siblings().removeClass("nav-first-active")

                break;
        }
    }

    // tabindex click
    $(".tabindex>ul>li").each(function () {
        this.onclick = function () {
            $(".tabindex>ul>li").removeClass('tab-active').addClass('tab-normal');
            $(this).addClass('tab-active').removeClass('tab-normal');
            $(".tb-bd").css("display","none")
            var currentIndex = $(this).index();
            switch (currentIndex){
                case 0:
                {
                   $(".tb-bd0").css("display","block");
                   break;
                }
                case 1:
                {
                    $(".tb-bd1").css("display","block");
                    break;
                }
                case 2:
                {
                    $(".tb-bd2").css("display","block");
                    break;
                }
                case 3:
                {
                    $(".tb-bd3").css("display","block");
                    break;
                }
            }
        }
    })
    
    
    // page active
    $(".page>button").each(function () {
        this.onclick = function () {
            $(".page>button").removeClass('page-active').addClass('page-normal');
           $(this).removeClass('page-normal').addClass('page-active');
        }
    })

    // Select and cancel
    $("#selectAll").click(function () {
        var content = $(this).text();
        var chk = $('input[name="subBox"]');
        if(content == "全选"){
            chk.prop("checked",true);
            $(this).css({"color":"inherit","border":"1px solid #c2c2c2"}).text("取消");

        }
        else if(content == "取消"){
            chk.prop("checked",false);
            $(this).css({"color":"#23c6c8","border":"1px solid #23c6c8"}).text("全选")
        }
        else{
            return
        }

    })

    // positive negative neutral
    // if($(".emotion").text().indexOf('正')!= -1){
    //     $(".emotion>label").addClass("positive")
    // }
    $(".emotion>label").each(function () {
        if($(this).text().indexOf('正')!= -1){
            $(this).addClass("positive")
        }
        else if($(this).text().indexOf('负')!= -1){
            $(this).addClass("negative")
        }
        else{
            $(this).addClass("neutral")
        }
    })
    // selected-list ---->chuangjianmianban.html

    var html;
    var arr = [];
    function createElement(checked,value) {
       var str = '<div class="selected-list"><span class="line1"></span><span class="line2"></span><span class="line3"></span>'
           +' <span class="line4"></span>'+value+'<i class="demo-icon icon-cancel"></i></div>'
            html += str;
            if(html.indexOf('undefined') != -1) {
                html = html.replace('undefined', '')
            }
        return html;
    }


    $(".jc-chk").each(function () {
        this.onclick = function () {
            var checked = $(this).children('input').prop('checked');
                var listItem = $(this).next().next().text();
                $("#listItem").html(createElement(checked,listItem))

            $(".icon-cancel").click(function () {

            })

        }
    })






    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    



})();